package demo.practice.binary_search;

public class P374 {
    int guess(int num){
        int pick= 6;
        if(num==pick)
            return 0;
        else if(pick < num)
            return -1;
        else
            return 1;

    }


    public int guessNumber(int n) {
        int min=1;

        int max=n;

        while (max>=min){
            int mid= min+(max-min)/2;

            int out =guess(mid);
            if(out==0)
                return mid;
            else if(out==-1){
                max=mid-1;
            }else
                min=mid+1;
        }

        return 1;
    }
}
